<?php
session_start();
require("design_admin_header.php");
require("../function/lang.php");
require("../function/config.inc.php");
require("../function/mysql.inc.php");
//Page index de l'administration.

$POST_VAR_LOGIN = $_POST['name'];
$POST_VAR_PASSW = $_POST['pass'];
$POST_VAR_PARTOFCREATION =  @empty($_POST['part']) ? -1 : $_POST['part'];
$GET_VAR_DELETEACH = @empty($_GET['deleteAch']) ? false : true;
$GET_VAR_ID =  @empty($_GET['a']) ? "" : $_GET['a'];
$GET_VAR_ID2 =  @empty($_GET['b']) ? "" : $_GET['b'];
$GET_VAR_CATID =  @empty($_GET['c']) ? -1 : $_GET['c'];
//Identification
if (!empty($_POST['name']) && !empty($_POST['pass'])) {
	if (in_array($POST_VAR_LOGIN, array_keys($CONFIG['admins'])) 
	&& ($CONFIG['admins'][$POST_VAR_LOGIN] == $POST_VAR_PASSW))
		$_SESSION['admin'] = $POST_VAR_LOGIN;
		$TITLE = $CONFIG['titleofwebsite']." | ".$ADMIN_TITLE_LOGIN[$Lang];
		
}
else
{
	$TITLE = $CONFIG['titleofwebsite']." | ".$ADMIN_TITLE_OTHER[$Lang];
	$GET_VAR_PAGE = $_GET['page'];
	$GET_VAR_PART = @empty($_GET['part']) ? $POST_VAR_PARTOFCREATION : $_GET['part'];
	if ($GET_VAR_PART == -1)
		$GET_VAR_PART = 0;
	//echo $GET_VAR_PART;
}
$SESSION_VAR_ADMIN = $_SESSION['admin'];
Design_Admin_Header($TITLE);
include '../menu.php';
echo "<br/><br/>";
//BODY
if (!(in_array($SESSION_VAR_ADMIN, array_keys($CONFIG['admins']))))
{
	include 'page_connection.php';
}
else
{
	if($GET_VAR_DELETEACH || ($GET_VAR_PAGE != "creation" && $GET_VAR_PAGE != "modifier" && $GET_VAR_PAGE != "joueur" ))
	{
		unset($_SESSION['AchTitle']); 
		unset($_SESSION['AchDesc']); 
		unset($_SESSION['AchCat']); 
		unset($_SESSION['Achimage']); 
		unset($_SESSION['Achamount']); 
		unset($_SESSION['Achonelife']); 
		unset($_SESSION['Achtaunt']);
		unset($_SESSION['Achtime']);
			
		unset($_SESSION['AchTypeofAchievement']);	
		//Kill
		unset($_SESSION['AchWhoWinKill']); 		 		
		unset($_SESSION['AchKillVictimSteamIDText']); 	
		unset($_SESSION['AchKillAttackSteamIDText']); 	
		unset($_SESSION['AchKillAssistSteamIDText']); 	
		unset($_SESSION['AchKillWeapon']); 				
		unset($_SESSION['AchKillMap']); 					
		unset($_SESSION['AchKillVictimclass']);			
		unset($_SESSION['AchKillAttackclass']); 			
		unset($_SESSION['AchKillAssistclass']); 			
		unset($_SESSION['AchKillCritz']); 
		unset($_SESSION['AchKillDomination']);
		unset($_SESSION['AchKillRevenge']); 		
		unset($_SESSION['AchKillHeadShot']); 	
		unset($_SESSION['AchKillBackstab']); 	
		unset($_SESSION['AchKillDeadRinger']); 			
		unset($_SESSION['AchKillAmount']);					
		//Sniper
		unset($_SESSION['AchSniperJarateRazor']); 		
		unset($_SESSION['AchSniperAttackVictim']); 		
		unset($_SESSION['AchSniperVictimSteamID']); 	
		unset($_SESSION['AchSniperAmount']); 			
		//Engineer
		unset($_SESSION['AchEngineerChoose']); 			
		unset($_SESSION['AchEngineerObjectName']);		
		unset($_SESSION['AchEngineerDestroy']); 			
		unset($_SESSION['AchEngineerDestroyBuild']);	
		unset($_SESSION['AchEngineerOwnerSteamID']);
		unset($_SESSION['AchEngineerUserSteamID']);
		unset($_SESSION['AchEngineerUserClass']);
		unset($_SESSION['AchEngineerSelfUse']);
		unset($_SESSION['AchEngineerAmount']); 			
		//Fun
		unset($_SESSION['AchFunRadio']);		 			
		unset($_SESSION['AchFunAmount']); 
		unset($_SESSION['AchFunRadioExact']);		 	
		unset($_SESSION['AchFunSayValue']);		 		
		unset($_SESSION['AchFunAmount']); 
		//Heavy
		unset($_SESSION['AchHeavySandwitch']);		 	
		unset($_SESSION['AchHeavySandwitchSteal']); 		
		unset($_SESSION['AchHeavyAmount']); 				
		//Hurt
		unset($_SESSION['AchWhoWinHurt']); 		 		
		unset($_SESSION['AchHurtAttackerSteamIDText']); 	
		unset($_SESSION['AchHurtVictimSteamIDText']); 	
		unset($_SESSION['AchHurtCritz']);			 	
		unset($_SESSION['AchHurtDmg_min']); 				
		unset($_SESSION['AchHurtDmg_max']); 	
		unset($_SESSION['AchHurtSelfdmg']);
		unset($_SESSION['AchHurtMap']);					
		unset($_SESSION['AchHurtAttacker_class']); 		
		unset($_SESSION['AchHurtVictim_class']); 		
		unset($_SESSION['AchHurtAmount']);				
		//Hurt
		unset($_SESSION['AchWhoWinTeamMap']); 		 	
		unset($_SESSION['AchMapCaperSteamIDText']); 		
		unset($_SESSION['AchMapName']); 					
		unset($_SESSION['AchMapNumberOfPoint']);			
		unset($_SESSION['AchMapMinCaper']); 				
		unset($_SESSION['AchMapMaxCaper'] );				
		unset($_SESSION['AchMapCapturerClass']);			
		unset($_SESSION['AchMapAmount']); 				
		//MEDIC
		unset($_SESSION['AchMedicUber']);	 		 	
		unset($_SESSION['AchMedicAmount']);	
		unset($_SESSION['AchMedicWho']); 
		unset($_SESSION['AchMedicAssistSteamID']); 	
		//Scout
		unset($_SESSION['AchScoutAchievements']);	 	
		unset($_SESSION['AchScoutAchievementsStunt']);	
		unset($_SESSION['AchScoutAmount']);		
		unset($_SESSION['AchScoutVictimSteamID']); 		
		//Condition
		unset($_SESSION['AchB2Conditon']);			
		unset($_SESSION['AchConditonWho']);		
		unset($_SESSION['AchB2Conditon']);
		unset($_SESSION['AchB2ConditonChapeau']);	
		unset($_SESSION['AchB2ConditonHealth1']);
		unset($_SESSION['AchB2ConditonHealth2']);		
		unset($_SESSION['partCreation']);
		
		unset($_SESSION['AchDemomanAmount']);
		unset($_SESSION['AchSoldierAction']);
		unset($_SESSION['AchSoldierAmount']);
		unset($_SESSION['AchSpyWho']);
		unset($_SESSION['AchSpyWho']);
		unset($_SESSION['AchSpyObjectName']);
		unset($_SESSION['AchSpyVictimSteamID']);
		unset($_SESSION['AchSpyAmount']);
	}
	unset($_SESSION['CatId']);
	unset($_SESSION['CatTitle']);
	if(!isset($GET_VAR_PAGE))
	{
		include 'admin.php';
	}
	else
	{
		if($GET_VAR_PAGE == "success")
		{
			include 'successOption.php';
		}
		elseif($GET_VAR_PAGE == "category")
		{
			include 'categoryOption.php';
		}
		elseif($GET_VAR_PAGE == "creation")
		{
			$POST_VAR_PARTOFCREATION = @empty($POST_VAR_PARTOFCREATION) ? 0 : $POST_VAR_PARTOFCREATION;
			$_SESSION['partCreation'] = @empty($_SESSION['partCreation']) ? array(0,0,0,0,0,0) : $_SESSION['partCreation'];
			include 'page_creation_achievm.php';
		}
		elseif($GET_VAR_PAGE == "supprimer")
		{
			if($GET_VAR_ID != "")
			{
				$selectMax = "SELECT * FROM `achmw_achievements` WHERE id = ".$GET_VAR_ID.";";
				$resultSelectMax = mysql_query($selectMax);
				$data = mysql_fetch_assoc($resultSelectMax); 
				$blocka_typ = $data['blocka_typ'];
				$blocka_id 	= $data['blocka_id'];
				
				$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
				$resultSelectMax = mysql_query($selectMax);
				
				$blocka_typ = $data['blockb_typ'];
				$blocka_id 	= $data['blockb_id'];
				
				$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
				$resultSelectMax = mysql_query($selectMax);
				
				$blocka_typ = $data['blockc_typ'];
				$blocka_id 	= $data['blockc_id'];
				
				$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
				$resultSelectMax = mysql_query($selectMax);
				
				$blocka_typ = $data['blockd_typ'];
				$blocka_id 	= $data['blockd_id'];
				
				$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
				$resultSelectMax = mysql_query($selectMax);
				
				$blocka_typ = $data['blocke_typ'];
				$blocka_id 	= $data['blocke_id'];
				
				$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
				$resultSelectMax = mysql_query($selectMax);
				
				$selectMax = "DELETE FROM `achmw_achievements` WHERE id = ".$GET_VAR_ID.";";
				$resultSelectMax = mysql_query($selectMax);
				
				$selectMax = "DELETE FROM `achmw_users_ach` WHERE achid = ".$GET_VAR_ID.";";
				$resultSelectMax = mysql_query($selectMax);
				
				include 'successOption.php';
				echo '<script type="text/JavaScript">';
				echo 'alert("'.$SUPPRESSOK[$Lang].'");';
				echo '</script>';
			}
			else
			{
				include 'successOption.php';
			}
		}
		elseif($GET_VAR_PAGE == "modifier")
		{
			$POST_VAR_PARTOFCREATION = @empty($POST_VAR_PARTOFCREATION) ? 0 : $POST_VAR_PARTOFCREATION;
			if($GET_VAR_ID != "")
			{
				$_SESSION['AchId'] 		= $GET_VAR_ID;
				$selectAch = "SELECT * FROM `achmw_achievements` WHERE id = ".$_SESSION['AchId'].";";
				//echo $selectAch;
				$resultSelectAch = mysql_query($selectAch);
				$data = mysql_fetch_assoc($resultSelectAch);
				
				$_SESSION['AchTitle'] 	= $data['name'];
				$_SESSION['AchDesc'] 	= $data['description'];
				$_SESSION['AchCat']		= $data['cat_id'];
				$_SESSION['Achimage'] 	= $data['img'];
				$_SESSION['Achamount']	= $data['amount'];
				$_SESSION['Achonelife']	= $data['ResetBlocksOnDeath'];
				$_SESSION['Achtaunt']	= $data['OnComplete'];
				$_SESSION['Achtime']	= $data['ResetTime'];
				
				$_SESSION['idNum'][1]				= $data['blocka_id'];
				$_SESSION['idNum'][2]				= $data['blockb_id'];
				$_SESSION['idNum'][3]				= $data['blockc_id'];
				$_SESSION['idNum'][4]				= $data['blockd_id'];
				$_SESSION['idNum'][5]				= $data['blocke_id'];
				
				$_SESSION['nameNum'][1]				= $data['blocka_typ'];
				$_SESSION['nameNum'][2]				= $data['blockb_typ'];
				$_SESSION['nameNum'][3]				= $data['blockc_typ'];
				$_SESSION['nameNum'][4]				= $data['blockd_typ'];
				$_SESSION['nameNum'][5]				= $data['blocke_typ'];
				
				$_SESSION['amountNum'][1]			= $data['blocka_max'];
				$_SESSION['amountNum'][2]			= $data['blockb_max'];
				$_SESSION['amountNum'][3]			= $data['blockc_max'];
				$_SESSION['amountNum'][4]			= $data['blockd_max'];
				$_SESSION['amountNum'][5]			= $data['blocke_max'];

				for($i=1;$i<6;$i++)
				{
					if($_SESSION['idNum'][$i] != "-1" && $_SESSION['idNum'][$i] != "0")
					{
						$_SESSION['AchIdTwo'][$i] = $_SESSION['idNum'][$i];
						if($_SESSION['nameNum'][$i] != "none" && $_SESSION['nameNum'][$i] != "")
						{
							$selectAch = "SELECT * FROM `achmw_blocks_".$_SESSION['nameNum'][$i]."` WHERE id = ".$_SESSION['idNum'][$i].";";
							//echo $selectAch;
							$resultSelectAch = mysql_query($selectAch);
							$data = mysql_fetch_assoc($resultSelectAch);
						}
						switch($_SESSION['nameNum'][$i])
						{
							case "callmedic": 
								$_SESSION['AchFunRadio'][$i]="2";
								$_SESSION['AchFunAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="fun";
							break;
							case "bonk": 
								$_SESSION['AchScoutAchievements'][$i]="bonk";
								$_SESSION['AchScoutAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="scout";
							break;
							case "capture": 
								if($data['captureteam']==1)
								{
									$_SESSION['AchWhoWinTeamMap'][$i] == "blu";
								}
								elseif($data['captureteam']==2)
								{
									$_SESSION['AchWhoWinTeamMap'][$i] == "red";
								}
								else
								{
									$_SESSION['AchWhoWinTeamMap'][$i] == "";
								}
								$_SESSION['AchMapName'][$i] = $data['map'];
								$_SESSION['AchMapCaperSteamIDText'][$i] = $data['capturer_id'];
								$_SESSION['AchMapNumberOfPoint'][$i] = $data['cp_id'];
								$_SESSION['AchMapMinCaper'][$i] = $data['min_cappers'];
								$_SESSION['AchMapMaxCaper'][$i] = $data['max_cappers'];
								$_SESSION['AchMapCapturerClass'][$i] = $data['capturer_class'];					
								$_SESSION['AchMapAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="map";
							break;
							case "eatsandwich": 
								$_SESSION['AchHeavySandwitch'][$i] = "own";
								$_SESSION['heavyAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="heavy";
							break;
							case "condition": 
								if($data['target']==0)
								{
									$_SESSION['AchConditonWho'][$i] = "victim";
								}
								elseif($data['target']==1)
								{
									$_SESSION['AchConditonWho'][$i] = "attacker";
								}
								else
								{
									$_SESSION['AchConditonWho'][$i] = "assist";
								}
								$_SESSION['AchB2Conditon'][$i] = $data['type'];
								if ($data['type'] == 1)
								{
									$_SESSION['AchB2ConditonHealth1'][$i] = $data['int1'];
									$_SESSION['AchB2ConditonHealth2'][$i] = $data['int2'];
								}
								elseif($data['type'] == 2)
								{
									$_SESSION['AchB2ConditonDistance1'][$i] = $data['int1'];
									$_SESSION['AchB2ConditonDistance2'][$i] = $data['int2'];
								}
								elseif($data['type'] == 3)
								{
									$_SESSION['AchB2ConditonChapeau'][$i] = $data['int1'];
								}
								$_SESSION['AchTypeofAchievement'][$i] ="condition";
							break;
							case "engineer_pda": 
								$_SESSION['AchEngineerChoose'][$i] = "build";
								if( $data['object'] == 3)
									$_SESSION['AchEngineerObjectName'][$i] = "sentry";
								elseif($data['object'] == 0)
									$_SESSION['AchEngineerObjectName'][$i] = "dispenser";
								elseif( $data['object'] == 1)
									$_SESSION['AchEngineerObjectName'][$i] = "teleentry";	
								elseif( $data['object'] == 2)
									$_SESSION['AchEngineerObjectName'][$i] = "teleexit";
								else
									$_SESSION['AchEngineerObjectName'][$i] = "";
								$_SESSION['AchEngineerAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="engineer";
							break;
							case "engineer_teleport": 
								$_SESSION['AchEngineerChoose'][$i] = "teleport";
								if($data['winner']==0)
								{
									$_SESSION['AchEngineerDestroy'][$i] = "victim";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchEngineerDestroy'][$i] = "attacker";
								}
								else
								{
									$_SESSION['AchEngineerDestroy'][$i] = "";
								}
								$_SESSION['AchEngineerOwnerSteamID'][$i] 	= $data['owner_id'];
								$_SESSION['AchEngineerUserSteamID'][$i] 	= $data['user_id'];
								$_SESSION['AchEngineerUserClass'][$i] 		= $data['user_class'];
								if($data['selfuse'] == 1)
								{
									$_SESSION['AchEngineerUserClass'][$i] 	= "yes";
								}
								else
								{
									$_SESSION['AchEngineerUserClass'][$i] 	= "no";
								}
								$_SESSION['AchEngineerAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="engineer";
							break;
							case "hurt": 
								if($data['winner']==0)
								{
									$_SESSION['AchWhoWinHurt'][$i] = "victim";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchWhoWinHurt'][$i] = "attacker";
								}
								else
								{
									$_SESSION['AchWhoWinHurt'][$i] = "";
								}
								$_SESSION['AchHurtAttackerSteamIDText'][$i] = $data['attacker_id'];
								$_SESSION['AchHurtVictimSteamIDText'][$i] = $data['victim_id'];
								$_SESSION['AchHurtCritz'][$i] = $data['crit'];
								$_SESSION['AchHurtDmg_min'][$i] = $data['dmg_min'];
								$_SESSION['AchHurtDmg_max'][$i] = $data['dmg_max'];
								$_SESSION['AchHurtSelfdmg'][$i] = $data['selfdmg'];
								$_SESSION['AchHurtMap'][$i] = $data['map'];
								$_SESSION['AchHurtAttacker_class'][$i] = $data['attacker_class'];
								$_SESSION['AchHurtVictim_class'][$i] = $data['victim_class'];
								$_SESSION['AchHurtAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="hurt";
							break;
							case "jarate": 
								$_SESSION['AchSniperJarateRazor'][$i] = "jarate";
								if($data['winner']==0)
								{
									$_SESSION['AchSniperAttackVictim'][$i] = "victim";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchSniperAttackVictim'][$i] = "attacker";
								}
								else
								{
									$_SESSION['AchSniperAttackVictim'][$i] = "";
								}
								$_SESSION['AchSniperVictimSteamID'][$i] = $data['steamid'];
								$_SESSION['AchSniperAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="sniper";
							break;
							case "kill": 
								if($data['selfdmg']==1)
								{
									$_SESSION['AchWhoWinKill'][$i] = "suicide";
								}
								elseif($data['winner']==0)
								{
									$_SESSION['AchWhoWinKill'][$i] = "victim";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchWhoWinKill'][$i] = "attacker";
								}
								elseif($data['winner']==2)
								{
									$_SESSION['AchWhoWinKill'][$i] = "assist";
								}
								$_SESSION['AchKillAttackSteamIDText'][$i] = $data['attacker_id'];
								$_SESSION['AchKillVictimSteamIDText'][$i] = $data['victim_id'];
								$_SESSION['AchKillAssistSteamIDText'][$i] = $data['assist_id'];
								$_SESSION['AchKillWeapon'][$i] = $data['killweapon'];
								$_SESSION['AchKillAttackclass'][$i] = $data['attacker_class'];
								$_SESSION['AchKillVictimclass'][$i] = $data['victim_class'];
								$_SESSION['AchKillAssistclass'][$i] = $data['assister_class'];
								
								$_SESSION['AchKillMap'][$i] = $data['map'];
								$_SESSION['AchKillCritz'][$i] = $data['crit'];
								if( $data['object'] == 3)
									$_SESSION['AchEngineerObjectName1'][$i] = "sentry1";
								elseif($data['object'] == 0)
									$_SESSION['AchEngineerObjectName1'][$i] = "dispenser1";
								elseif( $data['object'] == 1)
									$_SESSION['AchEngineerObjectName1'][$i] = "teleentry1";	
								elseif( $data['object'] == 2)
									$_SESSION['AchEngineerObjectName1'][$i] = "teleexit1";
								else
									$_SESSION['AchEngineerObjectName1'][$i] = "";
								if($data['was_build'] == 1)
								{
									$_SESSION['AchEngineerDestroyBuild1'][$i] 	= "yes";
								}
								elseif($data['was_build'] == 0)
								{
									$_SESSION['AchEngineerDestroyBuild1'][$i] 	= "no";
								}
								else
								{
									$_SESSION['AchEngineerDestroyBuild1'][$i] 	= "notimportant";
								}
								$_SESSION['AchKillDomination'][$i] 			= $data['domination'];
								$_SESSION['AchKillRevenge'][$i] 			= $data['revenge'];
								$_SESSION['AchKillHeadShot'][$i] 			= $data['headshot'];
								$_SESSION['AchKillBackstab'][$i] 			= $data['backstab'];
								$_SESSION['AchKillDeadRinger'][$i] 			= $data['deadringer'];
								$_SESSION['AchKillAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="kill";
							break;
							case "razorback": 
								$_SESSION['AchSniperJarateRazor'][$i] = "razor";
								if($data['winner']==0)
								{
									$_SESSION['AchSniperAttackVictim'][$i] = "victim";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchSniperAttackVictim'][$i] = "attacker";
								}
								else
								{
									$_SESSION['AchSniperAttackVictim'][$i] = "";
								}
								$_SESSION['AchSniperAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="sniper";
							break;
							case "say": 
								$_SESSION['AchFunRadio'][$i]="1";
								$_SESSION['AchFunSayValue'][$i]=$data['content'];
								$_SESSION['AchFunRadioExact'][$i]=$data['method'];
								$_SESSION['AchMapFun'][$i]=$data['map'];
								$_SESSION['AchFunAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="fun";
							break;
							case "sapped": 
								if($data['winner']==0)
								{
									$_SESSION['AchSpyWho'][$i] = "engineer";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchSpyWho'][$i] = "spy";
								}
								if( $data['object'] == 3)
									$_SESSION['AchSpyObjectName'][$i] = "sentry";
								elseif($data['object'] == 0)
									$_SESSION['AchSpyObjectName'][$i] = "dispenser";
								elseif( $data['object'] == 1)
									$_SESSION['AchSpyObjectName'][$i] = "teleentry";	
								elseif( $data['object'] == 2)
									$_SESSION['AchSpyObjectName'][$i] = "teleexit";
								else
									$_SESSION['AchSpyObjectName'][$i] = "";
								$_SESSION['AchSpyVictimSteamID'][$i]=$data['steamid'];
								$_SESSION['AchSpyAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="spy";
							break;
							case "stealsandwich": 
								$_SESSION['AchHeavySandwitch'][$i] = "other";
								if($data['winner']==0)
								{
									$_SESSION['AchHeavySandwitchSteal'][$i] = "victim";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchHeavySandwitchSteal'][$i] = "attacker";
								}
								else
								{
									$_SESSION['AchHeavySandwitchSteal'][$i] = "";
								}
								$_SESSION['AchHeavyAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="heavy";
							break;
							case "stunner": 
								$_SESSION['AchScoutAchievements'][$i] = "stunt";
								if($data['winner']==0)
								{
									$_SESSION['AchScoutAchievementsStunt'][$i] = "0";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchScoutAchievementsStunt'][$i] = "1";
								}
								else
								{
									$_SESSION['AchScoutAchievementsStunt'][$i] = "";
								}
								$_SESSION['AchScoutVictimSteamID'][$i] = $data['steamid'];
								$_SESSION['AchScoutAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="scout";
							break;
							case "stickyjump": 
								$_SESSION['AchDemomanAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="demoman";
							break;
							case "rocketjump": 
								$_SESSION['AchSoldierAction'][$i]="jump";
								$_SESSION['AchDemomanAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="soldier";
							break;
							case "banner": 
								$_SESSION['AchSoldierAction'][$i]="buff";
								$_SESSION['AchDemomanAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="soldier";
							break;
							case "ubercharge": 
								$_SESSION['AchMedicUber'][$i] = $data['weapons_uber'];
								if($data['winner']==0)
								{
									$_SESSION['AchMedicWho'][$i] = "medic";
								}
								elseif($data['winner']==1)
								{
									$_SESSION['AchMedicWho'][$i] = "assist";
								}
								else
								{
									$_SESSION['AchMedicWho'][$i] = "";
								}
								$_SESSION['AchMedicAssistSteamID'][$i] = $data['steamid'];
								$_SESSION['MedicAmount'][$i]=$_SESSION['amountNum'][$i];
								$_SESSION['AchTypeofAchievement'][$i] ="medic";
							break;
							default:
							$_SESSION['AchTypeofAchievement'][$i] ="none";
						}
						
					}
				}
				$_SESSION['partCreation'] = @empty($_SESSION['partCreation']) ? array(1,1,1,1,1,1) : $_SESSION['partCreation'];
				include 'page_modif_achievm.php';
			}
			elseif($_SESSION['AchId'] != "")
			{
				$_SESSION['partCreation'] = @empty($_SESSION['partCreation']) ? array(1,1,1,1,1,1) : $_SESSION['partCreation'];
				include 'page_modif_achievm.php';
			}
			else
			{
				include 'successOption.php';
			}
		}
		elseif($GET_VAR_PAGE == "visualise")
		{
			if($GET_VAR_ID2 != -1)
			{
				include 'successSpe.php';
			}
			else
			{
				include 'successOption.php';
			}
		}
		elseif($GET_VAR_PAGE == "supprimerSpe")
		{
			if($GET_VAR_ID2 != -1)
			{
				$selectMax = "SELECT * FROM `achmw_users_ach_spe` WHERE id = ".$GET_VAR_ID2.";";
				$resultSelectMax = mysql_query($selectMax);
				while ($rowUser = mysql_fetch_assoc($resultSelectMax)){
					$nameOfDelete =  $rowUser['title'];
				}
				$selectMax = "DELETE FROM `achmw_users_ach_spe` WHERE title = '".$nameOfDelete."';";
				$resultSelectMax = mysql_query($selectMax);
				include 'successOption.php';
				echo '<script type="text/JavaScript">';
				echo 'alert("'.$SUPPRESSOK[$Lang].'");';
				echo '</script>';
			}
		}
		elseif($GET_VAR_PAGE == "joueur")
		{
			if($GET_VAR_ID != -1)
			{
				$selectAll = "SELECT * FROM `achmw_achievements` WHERE id = ".$GET_VAR_ID.";";
				$resultSelectAll = mysql_query($selectAll);
				while ($data = mysql_fetch_assoc($resultSelectAll)) {
					$blocka_typ = $data['blocka_typ'];
					$blocka_id 	= $data['blocka_id'];
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blockb_typ'];
					$blocka_id 	= $data['blockb_id'];
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blockc_typ'];
					$blocka_id 	= $data['blockc_id'];
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blockd_typ'];
					$blocka_id 	= $data['blockd_id'];
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blocke_typ'];
					$blocka_id 	= $data['blocke_id'];
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_ach` WHERE achid = ".$data['id'].";";
					$resultSelectMax = mysql_query($selectMax);
				}
				include 'successOption.php';
				echo '<script type="text/JavaScript">';
				echo 'alert("'.$SUPPRESSOK[$Lang].'");';
				echo '</script>';
			}
			else
			{
				include 'successOption.php';
			}
		}
		elseif($GET_VAR_PAGE == "creationCat")
		{
			$POST_VAR_CATCREATION =  @empty($_POST['titleCat']) ? "" : $_POST['titleCat'];
			if ($POST_VAR_CATCREATION != "")
			{
				$POST_VAR_CATCREATION = str_replace("'","''",$POST_VAR_CATCREATION);
				$insertCat = "INSERT INTO `achmw_categories` VALUES (NULL,'".$POST_VAR_CATCREATION."');";
				mysql_query($insertCat);
				include 'categoryOption.php';
				echo '<script type="text/JavaScript">';
				echo 'alert("'.$CREATECATOK[$Lang].'");';
				echo '</script>';
			}
			else
			{
				include 'page_creation_cat.php';
			}
		}
		elseif($GET_VAR_PAGE == "supprimerCat")
		{
			if($GET_VAR_CATID != -1)
			{
				$selectAll = "SELECT * FROM `achmw_achievements` WHERE cat_id = ".$GET_VAR_CATID.";";
				$resultSelectAll = mysql_query($selectAll);
				while ($data = mysql_fetch_assoc($resultSelectAll)) {
					$blocka_typ = $data['blocka_typ'];
					$blocka_id 	= $data['blocka_id'];
					
					$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blockb_typ'];
					$blocka_id 	= $data['blockb_id'];
					
					$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blockc_typ'];
					$blocka_id 	= $data['blockc_id'];
					
					$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blockd_typ'];
					$blocka_id 	= $data['blockd_id'];
					
					$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$blocka_typ = $data['blocke_typ'];
					$blocka_id 	= $data['blocke_id'];
					
					$selectMax = "DELETE FROM `achmw_blocks_".$blocka_typ."` WHERE id = ".$blocka_id.";";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_blocks` WHERE block_id = ".$blocka_id." AND block_typ='".$blocka_typ."';";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_achievements` WHERE cat_id = ".$GET_VAR_CATID.";";
					$resultSelectMax = mysql_query($selectMax);
					
					$selectMax = "DELETE FROM `achmw_users_ach` WHERE achid = ".$data['id'].";";
					$resultSelectMax = mysql_query($selectMax);
				}
				$selectMax = "DELETE FROM `achmw_categories` WHERE id = ".$GET_VAR_CATID.";";
				$resultSelectMax = mysql_query($selectMax);
				include 'categoryOption.php';
				echo '<script type="text/JavaScript">';
				echo 'alert("'.$SUPPRESSOK[$Lang].'");';
				echo '</script>';
			}
			else
			{
				include 'categoryOption.php';
			}
		}
		elseif($GET_VAR_PAGE == "modifierCat")
		{
			$POST_VAR_CATMODIFTITLE 	=  @empty($_POST['titleCat']) ? "" : $_POST['titleCat'];
			$POST_VAR_CATMODIFID		=  @empty($_POST['idOfCat']) ? "" : $_POST['idOfCat'];
			if ($POST_VAR_CATMODIFTITLE != "" && $POST_VAR_CATMODIFID != "")
			{
				$POST_VAR_CATMODIFTITLE = str_replace("'","''",$POST_VAR_CATMODIFTITLE);
				$updateCat = "UPDATE `achmw_categories` SET `name` = '".$POST_VAR_CATMODIFTITLE."' 
				WHERE id = ".$POST_VAR_CATMODIFID.";";
				mysql_query($updateCat);
				include 'categoryOption.php';
				echo '<script type="text/JavaScript">';
				echo 'alert("'.$MODIFCATOK[$Lang].'");';
				echo '</script>';
			}
			else
			{
				if ($GET_VAR_CATID != -1)
				{
					$selectCat = "SELECT * FROM `achmw_categories` WHERE id = ".$GET_VAR_CATID.";";
					$resultSelectCat = mysql_query($selectCat);
					$data = mysql_fetch_assoc($resultSelectCat);
					$_SESSION['CatId'] 		= $data['id'];
					$_SESSION['CatTitle'] 	= $data['name'];
					include 'page_creation_cat.php';
				}
				else
				{
					include 'categoryOption.php';
				}
			}
		}
		elseif($GET_VAR_PAGE == "deco")
		{
			include 'page_deconnection.php';
			echo '<script type="text/JavaScript">';
			echo 'alert("'.$MENU_ADMIN_DECOOK[$Lang].'");';
			echo 'document.location.href="../index.php" ';
			echo '</script>';
		}
	}
}
?>

<?php
require("design_admin_foot.php");
Design_Admin_Foot();
?>
